package com.hqyj.listener;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 项目:rabbitmq-230301-summer
 * 描述:
 * 时间:2023/8/3 11:34
 * 作者:admin
 * 版本:1.0
 **/

//@Component
@Slf4j
public class TestListener {

    /**
     * 监听队列queue01的消息
     * @param channel 频道：在confirm机制，提供手动确认，不确认，拒绝的方法
     * @param message 消息对象：封装了消息和协议头的一个对象
     * @param map  消息对象
     */
    @RabbitListener(queues = "queue01")
    public String getListener(Channel channel, Message message, Map<String,Object> map) {
        log.info("message消息{}",message.toString());
        log.info("消息的编号:{}," +
                "消息的发送时间:{}," +
                "接收消息的交换机:{}",
                message.getMessageProperties().getDeliveryTag(),
                message.getMessageProperties().getTimestamp(),
                message.getMessageProperties().getReceivedExchange()
                );
        log.info("msg{}",map.get("msg"));
        return "200";
    }


}
